//
//  ZDMainViewController.swift
//  ZZDWeibo
//
//  Created by zzdan on 16/6/23.
//  Copyright © 2016年 zzdan. All rights reserved.
//

import UIKit

class ZDMainViewController: UITabBarController {

    override func viewDidLoad() {
       
        
        //自定义tabbar
        let tabBar = ZDTabBar()
        
        
        //设置代理
     tabBar.ZDDelegate = self

        
        setValue(tabBar, forKey: "tabBar")
        super.viewDidLoad()

        addViewChidViewController(ZDHomeTableViewController(), title: "首页", imageName: "tabbar_home")
//        
        addViewChidViewController(ZDMessageTableViewController(), title: "消息", imageName: "tabbar_message_center")
        addViewChidViewController(ZDDiscoveryTableViewController(), title: "发现", imageName: "tabbar_discover")
        addViewChidViewController(ZDProfileTableViewController(), title: "我", imageName: "tabbar_profile")
//
        
        
      }
    
    
    func addViewChidViewController(vc:UIViewController,title:String,imageName:String){
        
        vc.title = title
        
        vc.tabBarItem.image = UIImage(named: imageName)
        vc.tabBarItem.selectedImage = UIImage(named: "\(imageName)_selected")
        
        let nav = UINavigationController(rootViewController: vc)
        
        addChildViewController(nav)
        
    }
    
}

extension ZDMainViewController: ZDTabBarDelegate{
    func composeButtonClick(){
        
        print("弹出")
    }
        
}
